package com.hbnu.videotag.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hbnu.videotag.domain.VideoTag;
import com.hbnu.videotag.service.IVideoTagService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 视频标签多对多Controller
 * 
 * @author ruoyi
 * @date 2025-05-28
 */
@RestController
@RequestMapping("/prod-api/videotag/videotag")
public class VideoTagController extends BaseController
{
    @Autowired
    private IVideoTagService videoTagService;

    /**
     * 查询视频标签多对多列表
     */
    @PreAuthorize("@ss.hasPermi('videotag:videotag:list')")
    @GetMapping("/list")
    public TableDataInfo list(VideoTag videoTag)
    {
        startPage();
        List<VideoTag> list = videoTagService.selectVideoTagList(videoTag);
        return getDataTable(list);
    }

    /**
     * 导出视频标签多对多列表
     */
    @PreAuthorize("@ss.hasPermi('videotag:videotag:export')")
    @Log(title = "视频标签多对多", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VideoTag videoTag)
    {
        List<VideoTag> list = videoTagService.selectVideoTagList(videoTag);
        ExcelUtil<VideoTag> util = new ExcelUtil<VideoTag>(VideoTag.class);
        util.exportExcel(response, list, "视频标签多对多数据");
    }

    /**
     * 获取视频标签多对多详细信息
     */
    @PreAuthorize("@ss.hasPermi('videotag:videotag:query')")
    @GetMapping(value = "/{videoId}")
    public AjaxResult getInfo(@PathVariable("videoId") Long videoId)
    {
        return success(videoTagService.selectVideoTagByVideoId(videoId));
    }

    /**
     * 新增视频标签多对多
     */
    @PreAuthorize("@ss.hasPermi('videotag:videotag:add')")
    @Log(title = "视频标签多对多", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoTag videoTag)
    {
        return toAjax(videoTagService.insertVideoTag(videoTag));
    }

    /**
     * 修改视频标签多对多
     */
    @PreAuthorize("@ss.hasPermi('videotag:videotag:edit')")
    @Log(title = "视频标签多对多", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoTag videoTag)
    {
        return toAjax(videoTagService.updateVideoTag(videoTag));
    }

    /**
     * 删除视频标签多对多
     */
    @PreAuthorize("@ss.hasPermi('videotag:videotag:remove')")
    @Log(title = "视频标签多对多", businessType = BusinessType.DELETE)
	@DeleteMapping("/{videoIds}")
    public AjaxResult remove(@PathVariable Long[] videoIds)
    {
        return toAjax(videoTagService.deleteVideoTagByVideoIds(videoIds));
    }
}
